package com.kulian.Signalling.system.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.kulian.Signalling.common.annotation.Log;
import com.kulian.Signalling.common.enums.LogModuleEnum;
import com.kulian.Signalling.common.result.PageResult;
import com.kulian.Signalling.common.result.Result;
import com.kulian.Signalling.core.security.SecurityUtils;
import com.kulian.Signalling.system.mode.UserPageVO;
import com.kulian.Signalling.system.mode.query.UserPageQuery;
import com.kulian.Signalling.system.mode.vo.UserProfileVO;
import com.kulian.Signalling.system.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "02.用户接口")
@RestController
@RequestMapping("/api/v1/users")
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;


    @Operation(summary = "用户分页列表")
    @GetMapping("/page")
    @Log(value = "用户分页列表", module = LogModuleEnum.USER)
    public PageResult<UserPageVO> getUserPage(
            @Valid UserPageQuery queryParams
    ) {
        IPage<UserPageVO> result = userService.getUserPage(queryParams);
        return PageResult.success(result);
    }

    @Operation(summary = "获取个人中心用户信息")
    @GetMapping("/profile")
    @Log(value = "获取个人中心用户信息", module = LogModuleEnum.USER)
    public Result<UserProfileVO> getUserProfile() {
        Long userId = SecurityUtils.getUserId();
        UserProfileVO userProfile = userService.getUserProfile(userId);
        return Result.success(userProfile);
    }
}
